define([
    'zepto',
    'underscore',
    'backbone',
    "text!templates/success.html",
    "wTools"

], function ($, _, Backbone, template) {
    return Backbone.View.extend({
        $el: $main,
        el: $main0,
        template: _.template(template),
        events: {
            "tap #returnUrl":"returnUrl"
        },
        initialize: function () {
            $("#head_back").hide();
            $("#home").html("");
            this.render();
            var timeFiv = 5;
            $("#resultMsg").html("支付成功," + timeFiv + "s后自动返回");
            var IntervalNum = setInterval(function () {
                timeFiv--;
                if (timeFiv == 0) {
                    clearInterval(IntervalNum);
                    if(wData.orderInfo.returnUrl!=undefined&&wData.orderInfo.returnUrl!=null&&wData.orderInfo.returnUrl!="") {
                        location.href = wData.orderInfo.returnUrl.replace(/&amp;/g,'&');
                    }
                    //返回地址backURL;
                } else {
                    $("#resultMsg").html("支付成功," + timeFiv + "s后自动返回");
                }
            }, 1000);
        },


        //返回地址跳转
        returnUrl: function () {
            if(wData.orderInfo.returnUrl!=undefined&&wData.orderInfo.returnUrl!=null&&wData.orderInfo.returnUrl!="") {
                location.href = wData.orderInfo.returnUrl.replace(/&amp;/g,'&');
            }

        },

        back: function () {
            //history.back();
        },
        render: function (data) {
            var html = this.template(data);
            this.$el.html(html);
        },
        destroy: function () {
            this.undelegateEvents();
            this.$el.html("");
            $("#head_back").show();
            delete this;
        }
    });
});